<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>忘记密码</title>
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">

    <!--标准mui.css-->
    <link rel="stylesheet" href="__PUBLIC__/css/mui.min.css">
    <!--App自定义的css-->
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/css/app.css" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/css/login.css" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/css/icon.css" />
</head>

<body class="bgf">
<header class="mui-bar mui-bar-nav">
    <a onclick="location.href='/index.php?g=YunCangChu&m=login&a=index'" class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
    <h1 class="mui-title">忘记密码</h1>
</header>
<div class="mui-content">
    <div id="tabbar" class="mui-control-content mui-active">
        <form class="mui-input-group">
            <div class="mui-input-row h50">
                <i class="mui-login-all wj-phone-icon  mui-pull-left"></i>
                <label class="pl40">手机号</label>
                <input id="phone" type="text" class=" login-inp mt5 mui-input-clear mui-input mui-yuuye" placeholder="请输入手机号">
            </div>
            <div class="mui-input-row h50">
                <i class="mui-login-all wj-yanzhengma-icon  mui-pull-left"></i>
                <label class="pl40">验证码</label>
                <input id="yzm" type="text" class="login-inp mt5 mui-input-clear mui-input mui-yuuye" placeholder="请输入验证码">
                <span  class="hqyzm">获取验证码</span>
            </div>
            <div class="mui-input-row h50">
                <i class="mui-login-all wj-mima-icon  mui-pull-left"></i>
                <label class="pl40">密码</label>
                <input id="password" type="password" class="login-inp mt5 mui-input-clear mui-input mui-yuuye" placeholder="请输入密码">
            </div>
            <div class="mui-input-row h50">
                <i class="mui-login-all wj-queren-icon  mui-pull-left"></i>
                <label class="pl40">确认密码</label>
                <input id="querenpassword" type="password" class="login-inp mt5 mui-input-clear mui-input mui-yuuye" placeholder="请确认密码">
            </div>

        </form>
        <button id="querenxiguan" type="button" class="mb20 mui-btn-sz ">确认修改</button>
    </div>

</div>
</body>
<script src="__PUBLIC__/js/jquery-3.2.1.min.js"></script>
<script src="__PUBLIC__/js/mui.min.js"></script>
<script src="__PUBLIC__/layer_mobile/layer.js"></script>
<script>
    $(function(){
        var num = 60;
        var time;
        $(".hqyzm").click(function(){
            var phone = $('#phone').val()
            if(isMobileNumber(phone) === false)
            {
                return false
            }
            else
            {
                $.post("{:U('fyzm1')}",{phone:phone},function (rel) {
                    layer.open({
                        content: rel.msg
                        ,btn: '我知道了'
                    });
                })
            }
            clearInterval(time);
            $(this).html(num);
            time = setInterval(function(){
                num--;
                $(".hqyzm").html(num);
                if(num == 0){
                    num = "重新获取";
                    $(".hqyzm").html(num);
                    clearInterval(time);
                }
            },1000)
        })
    })
    //修改密码
    $('#querenxiguan').click(function () {
        var phone = $('#phone').val()
        var yzm = $('#yzm').val()
        var password =  $('#password').val()
        var queren =  $('#querenpassword').val()
        if(phone == "" || yzm=='' || password=='' || queren=='')
        {
            layer.open({
                content: '请添加必填项'
                ,btn: '我知道了'
            });
            return false
        }
        if(password != queren)
        {
            layer.open({
                content: '密码和确认密码不相同'
                ,btn: '我知道了'
            });
            return false
        }
        $.post("{:U('zhaohui')}",{phone:phone,yzm:yzm,password:password,queren:queren},function(rel) {

                layer.open({
                    content: rel.msg
                    ,btn: '我知道了'
                });

        })
    })
</script>
<script>
    function isMobileNumber(phone) {
        var flag = false;
        var message = "";
        var myreg = /^(((13[0-9]{1})|(14[0-9]{1})|(17[0-9]{1})|(15[0-3]{1})|(15[4-9]{1})|(18[0-9]{1})|(199))+\d{8})$/;
        if (phone == '') {
            // console.log("手机号码不能为空");
            message = "手机号码不能为空！";
        } else if (phone.length != 11) {
            //console.log("请输入11位手机号码！");
            message = "请输入11位手机号码！";
        } else if (!myreg.test(phone)) {
            //console.log("请输入有效的手机号码！");
            message = "请输入有效的手机号码！";
        } else {
            flag = true;
        }
        if (message != "") {
            layer.open({
                content: message
                ,btn: '我知道了'
            });
            return false
        }
        return flag;
    }
</script>
</html>
